﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Semesters.aspx.cs" Inherits="Web.Semesters" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Main" runat="server">

    <asp:UpdatePanel ID="UpdatePanelStudyYears" runat="server">
        <ContentTemplate>

            <section id="StudyYearsSection" class="inset-shadow box w300 left">

                <header>
                    <h3>Учебные годы</h3>

                    <% if (PermissionService.CanCUDSemesters())
                       { %>
                    <div class="right-top cud-links">
                        <asp:LinkButton runat="server" ID="BtnAddStudyYear" Text="Добавить" ToolTip="Добавить новый учебный год" OnClick="BtnAddStudyYear_OnClick" />
                    </div>
                    <% } %>
                </header>

                <% if (PermissionService.CanCUDSemesters())
                   { %>
                <aside runat="server" id="EditStudyYearForm" visible="False">
                    <div runat="server" id="EditStudyYearFormError" class="form-error" />
                    <table class="form">
                        <tr>
                            <td>Начало:</td>
                            <td>
                                <asp:TextBox runat="server" ID="TbStudyYearBeginDate" CssClass="datepicker" />
                            </td>
                        </tr>
                        <tr>
                            <td>Конец:</td>
                            <td>
                                <asp:TextBox runat="server" ID="TbStudyYearEndDate" CssClass="datepicker" />
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button runat="server" ID="ButtonSaveStudyYear" Text="Сохранить" CssClass="button" OnClick="ButtonSaveStudyYear_OnClick" />
                                <asp:Button runat="server" ID="ButtonDeleteStudyYear" Text="Удалить" CssClass="button" OnClientClick="return confirm('Точно удалить?');" OnClick="ButtonDeleteStudyYear_OnClick" />
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button runat="server" ID="ButtonCancelStudyYear" Text="Отменить" CssClass="button" OnClick="ButtonCancelStudyYear_OnClick" />
                            </td>
                        </tr>
                    </table>
                </aside>
                <% } %>

                <asp:ListView runat="server" ID="ListViewStudyYears" DataKeyNames="Id">

                    <LayoutTemplate>
                        <asp:PlaceHolder ID="ItemPlaceholder" runat="server" />
                    </LayoutTemplate>

                    <ItemTemplate>
                        <article class="border-top-silver clear-fix">
                            <header>
                                <h5>
                                    <asp:HyperLink runat="server" NavigateUrl='<%# string.Format("/Semesters.aspx?StudyYearId={0}", Eval("Id")) %>' Text='<%# Eval("Name") %>' />
                                </h5>

                                <% if (PermissionService.CanCUDSemesters())
                                   { %>
                                <div class="right-top cud-links">
                                    <asp:LinkButton runat="server" ID="BtnChangeStudyYear" Text="Изменить" ToolTip="Изменить учебный год" OnClick="BtnChangeStudyYear_OnClick" />
                                </div>
                                <% } %>
                            </header>

                            <p>
                                Начало:
                                    <asp:Label runat="server" Text='<%# Eval("BeginDate") %>' />
                            </p>
                            <p>
                                Конец:
                                    <asp:Label runat="server" Text='<%# Eval("EndDate") %>' />
                            </p>
                        </article>
                    </ItemTemplate>

                    <EmptyDataTemplate>
                        Не добавлено ни одного учебного года
                    </EmptyDataTemplate>

                </asp:ListView>

            </section>

        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdatePanel ID="UpdatePanelSemesters" runat="server">
        <ContentTemplate>
            <section runat="server" id="SemestersSection" visible="False" class="inset-shadow box w400 left">

                <header>
                    <h3>Семестры за <%= CurrentStudyYear.Name %> год</h3>

                    <% if (PermissionService.CanCUDSemesters())
                       { %>
                    <div class="right-top cud-links">
                        <asp:LinkButton runat="server" ID="BtnAddSemester" Text="Добавить" ToolTip="Добавить новый семестр" OnClick="BtnAddSemester_OnClick" />
                    </div>
                    <% } %>
                </header>

                <% if (PermissionService.CanCUDSemesters())
                   { %>
                <div runat="server" id="EditSemesterForm" visible="False">
                    <div runat="server" id="EditSemesterFormError" class="form-error" />
                    <table class="form">
                        <tr>
                            <td>Начало:</td>
                            <td>
                                <asp:TextBox runat="server" ID="TbSemesterBeginDate" CssClass="datepicker" />
                            </td>
                        </tr>
                        <tr>
                            <td>Конец:</td>
                            <td>
                                <asp:TextBox runat="server" ID="TbSemesterEndDate" CssClass="datepicker" />
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button runat="server" ID="ButtonSaveSemester" Text="Сохранить" CssClass="button" OnClick="ButtonSaveSemester_OnClick" />
                                <asp:Button runat="server" ID="ButtonDeleteSemester" Text="Удалить" CssClass="button" OnClick="ButtonDeleteSemester_OnClick" />
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button runat="server" ID="ButtonCancelSemester" Text="Отменить" CssClass="button" OnClick="ButtonCancelSemester_OnClick" />
                            </td>
                        </tr>
                    </table>
                </div>
                <% } %>

                <asp:ListView runat="server" ID="ListViewSemesters" DataKeyNames="Id">

                    <LayoutTemplate>
                        <asp:PlaceHolder ID="ItemPlaceholder" runat="server" />
                    </LayoutTemplate>

                    <ItemTemplate>
                        <article class="border-top-silver clear-fix">
                            <header>
                                <h5>
                                    <%# Eval("SemesterNumber") %>-й семестр
                                </h5>

                                <% if (PermissionService.CanCUDSemesters())
                                   { %>
                                <div class="right-top cud-links">
                                    <asp:LinkButton runat="server" ID="BtnChangeSemester" Text="Изменить" ToolTip="Изменить семестр" OnClick="BtnChangeSemester_OnClick" />
                                </div>
                                <% } %>
                            </header>

                            <p>
                                Начало:
                                    <asp:Label runat="server" Text='<%# Eval("BeginDate") %>' />
                            </p>
                            <p>
                                Конец:
                                    <asp:Label runat="server" Text='<%# Eval("EndDate") %>' />
                            </p>
                        </article>
                    </ItemTemplate>

                    <EmptyDataTemplate>
                        Не добавлено ни одного семестра
                    </EmptyDataTemplate>

                </asp:ListView>

            </section>
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
